home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- #include <stdio.h>
- #include "gl.h"
- #include "pick.h"
-
-
- /*
- * routines to use 32 bit integers in the 16 bit name mechanism
- */
- pushLongName(longName)
- long longName;
- {
- pushname(longName & 0xffff); /* high bits of name */
- pushname(longName >> 16); /* low bits of name */
- }
-
- popLongName()
- {
- popname();
- popname();
- }
-
- Object
- getLongName(base)
- short *base;
- {
- return (Object)((*base & 0xffff) | (*(base+1) << 16));
- }
-
- /*
- * hit processing utilities
- */
- gethit(hit, base, found)
- register hitstruct *hit;
- register short base[];
- register short found;
- {
- register short i, names, obase;
-
- /* dumplist(base, found); /* */
-
- if (found <= 0) {
- if (found <0)
- fprintf(stderr, "gethit: hey, hits overflowed the hitlist!\n");
- return 0;
- }
-
- i = 0;
- while (found-- > 1) {
- names = base[i++];
- while (names--)
- obase = base[i++]; /* obase is only used to debug */
- }
- /* last found hit entry */
- if ((names = base[i++]) >= 0) {
- names -= 4; i += 4; /* step over initial NULL and "us" entries */
- for (hit->depth=0; names>0; names-=2, i+=2)
- hit->hitlist[hit->depth++] = getLongName(&base[i]);
- /* fprintf(stderr, "gethit: returns %d\n", hit->depth); /* */
- return hit->depth;
- }
- else fprintf(stderr,"gethit: trouble in the hitlist! names = %d\n", names);
-
- return 0;
- }
-
- dumplist(base, found)
- register short base[];
- register short found;
- {
- register short i, names;
-
- fprintf(stderr,"dumplist: found %d %s\n", found, (found>1)?"hits":"hit");
- if (found < 0)
- found = HITENTRIES;
- i = 0;
- while (found--) {
- if ((names = base[i++]) <= 0) {
- continue;
- }
- else {
- fprintf(stderr,"\t%d names", names);
- while (names-- && (i<HITENTRIES))
- fprintf(stderr,",0x%x", base[i++]);
- fprintf(stderr,"\n");
- }
- }
- fflush(stderr);
- }
-